export default {
  //商品类型列表
  loadCategoryServer(params,callback) {
    Vue.http.get('/goods/category/tree.json',{params:params}).then((response)=> {
      callback(response.data);
    });
  },
  //添加商品类型
  addCategoryServer(params,callback_success,callback_error) {
    Vue.http.post('/goods/category/add.json',params).then( (response)=> {
      callback_success(response.data);
    },response=>{
      callback_error(response.data);
    });
  },
  //删除商品类型
  deleteCategoryServer(params,callback) {
    Vue.http.delete('/goods/category/remove.json',{params:params}).then(response=>{
      callback(response.data);
    });
  },
  //编辑商品类型
  editCategoryServer(params,callback_success,callback_error) {
    Vue.http.put('/goods/category/modify.json',params).then( (response) =>{
      callback_success(response.data);
    },response=>{
      callback_error(response.data);
    });
  },
  //删除文件
  deleteFileServer(params,callback) {
    Vue.http.delete('/file/delete.json',{params:params}).then(response=>{
      callback(response.data);
    });
  },
  //专题列表
  loadSubjectServer(params,callback) {
    Vue.http.get('/goods/subject/listdata.json',{params:params}).then( (response)=> {
      callback(response.data);
    });
  },
  // 获取站点列表
  // loadSiteListServer(callback) {
  //   Vue.http.get('/seller/siteList.json').then( (response)=>{
  //     callback(response.data);
  //   });
  // },
  //商品列表
  loadProductServer(params,callback) {
    Vue.http.get('/goods/listpage.json',{params:params}).then( (response)=>{
      callback(response.data);
    });
  },
  //商品排序
  productSortServer(params,callback_success,callback_error) {
    Vue.http.put('/goods/sort.json',params).then( (response) =>{
      callback_success(response.data);
    },response=>{
      callback_error(response.data);
    });
  },
  //商品上下架
  upOrDownGoodsServer(params,callback_success,callback_error) {
    Vue.http.put('/goods/platform/publish.json',params).then( (response) =>{
      callback_success(response.data);
    },response=>{
      callback_error(response.data);
    });
  },
  //添加商品专题
  addSubjectServer(params,callback_success,callback_error) {
    Vue.http.post('/goods/subject/add/relation.json',params).then( (response)=> {
      callback_success(response.data);
    },response=>{
      callback_error(response.data);
    });
  },
  //删除商品专题
  deleteSubjectServer(params,callback_success,callback_error) {
    Vue.http.delete('/goods/subject/cancel/relation.json',{params:params}).then( (response)=> {
      callback_success(response.data);
    },response=>{
      callback_error(response.data);
    });
  },
  //商品详情
  loadProductDetail(params,callback) {
    Vue.http.get('/goods/detail/'+params.id+'.json').then( (response)=>{
      callback(response.data);
    });
  },
  //查询商品价格
  loadPriceByAttr(params,callback) {
    Vue.http.get('/goods/detail/attribute/'+params.goodsId+'.json',{params:{attributeIds:params.attributeIds}}).then(response=> {
      callback(response.data);
    });
  }
}
